<template>
  <el-table
    :data="list"
    style="width: 100%">
    <el-table-column
      prop="title"
      label="课程名称"
      width="180">
    </el-table-column>
    <el-table-column

      label="课程状态"
      width="180">
      <template slot-scope="scope">
        {{ scope.row.status==='Normal'?'已发布':'未发布' }}
      </template>
    </el-table-column>
    <el-table-column
      prop="lessonNum"
      label="课时数">
    </el-table-column>
    <el-table-column
      prop="gmtCreate"
      label="添加时间">
    </el-table-column>
    <el-table-column
      prop="viewCount"
      label="浏览数量">
    </el-table-column>
    <el-table-column
      prop=""
      label="操作">
      <template slot-scope="scope">
        <router-link :to="'/teacher/edit/' + scope.row.id">
          <el-button type="primary" size="mini" icon="el-icon-edit">
            编辑课程基本信息 >
          </el-button>
        </router-link>
        <router-link :to="'/teacher/edit/' + scope.row.id">
          <el-button type="primary" size="mini" icon="el-icon-edit" >
            编辑课程大纲信息 >
          </el-button>
        </router-link>
        <el-button type="danger" size="mini" icon="el-icon-delete" @click="removeCourse(scope.row.id)">
          删除课程信息
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
  import subject from "@/api/teacher/subject";

  export default {
    created() {
      this.getCourseListFn()
    },
    data() {
      return {
        list: []
      }
    },
    methods: {
      removeCourse(id){
        subject.deleteCourse(id).then(res=>{
          this.$message({
            type: 'success',
            message: '删除课程成功!'
          })
          this.getCourseListFn()
        })
      },
      getCourseListFn() {
        subject.getListCourse().then(res => {

          this.list = res.data.list
        })
      }
    }
  }
</script>

<style scoped>

</style>
